package com.weiawei.component;

import javax.swing.*;
import java.awt.*;

public class BackGroundPannel extends JPanel {
    //声明图片
    private Image backpicture ;
    public  BackGroundPannel (Image backpicture)
    {
        this.backpicture = backpicture ;
    }

    // 把图片内容声明为背景 重写paint方法
    // 内容应该由panel自己绘制
    //graphics 绘图类的对象，用于绘图
    @Override
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        g.drawImage(backpicture,0,0,this.getWidth(),this.getHeight(),null );
    }


}
